
<template>
    <div>
        <!--面包屑导航区域-->
        <el-breadcrumb separator-class="el-icon-arrow-right" style="margin-bottom: 20px;">
            <el-breadcrumb-item :to="{ path: '/index' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>查看订单</el-breadcrumb-item>
        </el-breadcrumb>
        <!--卡片视图区域-->
        <el-card>
            <!--<el-row style="margin-bottom: 20px;">
                <el-col :span="6">
                    <el-input placeholder="请输入内容"
                                size="small">
                        <el-button slot="append" icon="el-icon-search"
                        size="small"></el-button>
                    </el-input>
                </el-col>
            </el-row>-->
            <!--订单列表数据-->
            <el-table :data="orderList" border strip
                      style="width: 100%"
                      :cell-style="cell_style"
                      :header-cell-style="header_style"
                        size="small">
                <el-table-column label="订单编号" prop="orderId"></el-table-column>
                <el-table-column label="下单时间" prop="createTime"></el-table-column>
                <el-table-column label="餐桌编号" prop="seatsId"></el-table-column>
                <el-table-column label="订单状态" prop="orderState"></el-table-column>
                <el-table-column label="订单消费" prop="totalPrice"></el-table-column>
                <el-table-column label="操作">
                    <template slot-scope="scope">
                        <el-button type="primary" size="small"
                                   @click="dialogTableVisible = true">查看详情</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <!--分页区域-->
            <el-pagination @current-change="changePage"
                           :current-page="query.currentPage"
                            :page-size="5"
                            background
                            layout="prev, pager, next"
                            :total="page.totalSize">
            </el-pagination>
        </el-card>
        <!--查看详情的对话框-->
        <el-dialog title="查看订单详情" :visible.sync="dialogTableVisible" style="text-align: left">
            <el-table :cell-style="cell_style"
                      :header-cell-style="header_style"
                      size="small" :data="details">
                <el-table-column property="dishName" label="菜品名称" width="150"></el-table-column>
                <el-table-column property="dishPrice" label="单价" width="200"></el-table-column>
                <el-table-column property="dishNum" label="数量"></el-table-column>
            </el-table>
        </el-dialog>
    </div>
</template>
<script>
    import axios from '../../http/http'
    import bus from '../../bus'
    export default {
        name:'syn_ckdd',
        data(){
            return {
                orderList: [],
                dialogTableVisible : false,
                query:{
                    currentPage:1,
                    pageSize:5
                },
                page:{
                    totalSize:0
                },
                details:[{
                    dishName:'蒜苗回锅肉',
                    dishPrice:16,
                    dishNum:1
                }]
            }
        },
        methods:{
            getOrderList(){
                return axios({
                    url:'rms/front/order/query',
                    method:'post',
                    headers:{
                        'Content-type': 'application/json'
                    },
                    data:{
                        "orderId":'string',
                        "pager":{
                            currentPage:1,
                            pageSize:5
                        },
                        "seatNumber":'string',
                        "state":'string',
                        "type":'string'
                    }
                }).then(res=>{
                    // console.log(res.data);
                    this.orderList = res.data.info;
                    this.page = res.data.pager;
                    this.orderList.forEach(item=>{
                       if(item.orderState === 0){
                           item.orderState = '已完成'
                       } else{
                           item.orderState = '未完成'
                       }
                    });
                })
            },
            changePage(newPage) {
                this.page.currentPage = newPage;
                this.getOrderList();
            },
            cell_style(row, column, rowIndex, columnIndex) {
                return ' text-align: center';
            },
            header_style(row, rowIndex) {
                return ' text-align: center;';
            }
        },
        created() {
            this.getOrderList();
        }
    }
</script>
<style lang="less" scoped>

</style>